package com.gome.splunk;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;

public class PreferenceUtils {
	
	private  SharedPreferences prefs = null;
	
	private static PreferenceUtils mPreferenceUtils;

	
    public PreferenceUtils(SharedPreferences prefs) {
		super();
		this.prefs = prefs;
	}

	public static PreferenceUtils getInstance(Context ctx) {

        if (ctx == null) {
            //BDebug.e("Context is null ", "ctx == null");
        	Log.e("splunk", "Context is null ");
        }

        if (mPreferenceUtils == null) {
        	mPreferenceUtils = new PreferenceUtils(ctx.getSharedPreferences("splunk_cookies", Context.MODE_PRIVATE));
        }
        return mPreferenceUtils;
    }

    public  String getStringValue(String key, String value) {
        return prefs.getString(key, value);
    }

    public  void setStringValue(String key, String value) {
        Editor editor = prefs.edit();
        editor.putString(key, value);
        editor.commit();
    }

    public  String getCookies() {
        return getStringValue("cookies","");      
    }

    public  void setCookies(String cookies) {
        setStringValue("cookies", cookies);
    }

   





}
